home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / MATH / RANDOMGN / APPRAND.PAS < prev    next >
Pascal/Delphi Source File  |  1991-06-28  |  1KB  |  47 lines

  1. program AppendRandom;
  2. {
  3.    Sample program to show how to access the RANTSR random number
  4.    generator.  Since RANTSR generates only one byte per keystroke,
  5.    it is best to use the generator only to seed a traditional
  6.    pseudo-random number generator
  7.  
  8.    Joseph R Ahlgren     BBS 703-241-7980        }
  9.  
  10. {$N-}
  11.   uses Dos;
  12.   var
  13.     f: file;
  14.     r: registers;
  15.     a: array [1..256] of byte;
  16.   begin
  17.     {ask for 0 bytes, just to see if RANTSR is loaded}
  18.     r.ax:=$ae00;
  19.     r.dx:=$726e;
  20.     r.es:=seg(a);
  21.     r.di:=ofs(a);
  22.     intr($2f,r);
  23.     WriteLn('al status=',r.al,'  dx status=',r.dx);
  24.     if (r.al = $ff) and (r.dx = 0) then
  25.       begin
  26.       {ask for 255 bytes}
  27.       r.ax:=$aeff;
  28.       r.dx:=$726e;
  29.       r.es:=seg(a);
  30.       r.di:=ofs(a);
  31.       intr($2f,r);
  32.       WriteLn(r.dx,' random bytes returned, status=',r.al);
  33.       assign(f,'random.log');
  34.       {$I-}
  35.       reset(f,1);
  36.       if IOresult <> 0 then
  37.         {$I+}
  38.         rewrite(f,1)
  39.        else
  40.         seek(f,filesize(f));
  41.       blockwrite(f,a,r.dx);
  42.       WriteLn('New RANDOM.LOG file size is ',filesize(f),' bytes.');
  43.       close(f);
  44.       end
  45.      else
  46.       WriteLn('INT 2F did not return a valid signature, RANTSR not found');
  47. end.